<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机生成指定长度的字符串</title>
</head>
<body>
    <div id="result"></div>

    <script>
        
        function getLetters0(unicodeValue) {
            return String.fromCharCode(unicodeValue);
        }

        
        function randomString0(n) {
            var result = '';
            for (var i = 0; i < n; i++) {
                
                var unicodeValue = Math.floor(Math.random() * (90 - 65 + 1)) + 65;
                
                result += getLetters0(unicodeValue);
            }
            return result;
        }

       
        console.log(randomString0(3));
    </script>
</body>
</html>